<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <meta name="renderer" content="webkit|ie-comp|ie-stand">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
  <meta http-equiv="Cache-Control" content="no-siteapp" />
  <title>付费版测试</title>
</head>

<body>
  <div id="app" element-loading-text="付费版测试页面加载中..." v-loading.fullscreen.lock="loading">

  </div>
</body>

<script src="../../myJs/importFile.js"></script>
<script>
  importFile();
</script>
<script>
  var app = new Vue({
    el: '#app',
    data: function () {
      return {
        loading: false
      };
    },

    created: function () {
      this.loading = true;
      var self = this;
      this.toLogin().then(function (flag) {
        if (!flag) {
          self.loading = false;
          return;
        }

        self.setUser().then(function (user) {
          self.loading = false;
          if (user === null) {
            return;
          }

          window.parent.window.location.reload(true);
        });
      });
    },

    methods: {
      toLogin: function () {
        var self = this;
        return ajaxRequest('user/loginByVerificationCode', {
          company: '付费试用',
          userName: '付费试用',
          password: '123'
        }).then(function () {
          return true;
        }).catch(function () {
          return false;
        });
      },

      setUser: function () {
        return ajaxRequest('user/getUserName', {}, false, false).then(function (res) {
          if (!res.result) {
            return null;
          }

          var user = res.data;
          SysUtil.formatUserInfo(user);
          window.sessionStorage.clear();
          window.sessionStorage.setItem('user', JSON.stringify(user));
          return user;
        }).catch(function () {
          return null;
        });
      }
    }
  });
</script>

</html>